<?php
header("Access-Control-Allow-Origin:*");
require("../lib/init.php");
require("../pojo/token.php");
$words = $_POST['words'];
$token = $_POST['token'];
if (empty($token) or empty($words)){
    exit("缺少必要参数");
}
if (!checkToken($token)) {
    $code = 400;
    $msg ="没有权限";
} else {
    $sql = "select * from role where roleName like '%$words%'";
    if (!MQuery($sql)) {
        $code = 400;
        $msg = "查询失败！";
        $data =array(
            "roles"=>"查询失败"
        );
    } else {
        $code = 200;
        $msg = "查询成功！";
        $data =array(
            "roles"=>Mgetall($sql)
        );
    }
}

echo json_encode(result($code, $msg, $data));
